﻿@model ShenLanCMS.Models.Post
@{
    ViewBag.Title = Model.Title;
    Layout = "~/Views/Shared/_PublicLayout.cshtml";
}
<script src="../../Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#btncomment").click(function () {
            if (checomment()) {
                $.ajax({
                    type: "post",
                    url: "/comment/postcomment?postid=@Model.PostID" + "&nickname=" + $("#nickname").val() + "&email=" + $("#email").val() + "&siteurl=" + $("#siteurl").val() + "&comment=" + $("#comment").val(),
                    success: function (data) {
                        alert(data);
                        if (data == "评论成功") {
                            getcomment();
                        }
                    }
                });
            }
        });

        //顶文章
        $("#dgood").click(function () {
            $.post("/post/dig?mod=good&id=@Model.PostID", function (data) {
                alert(data);
                if (data == "操作成功") {
                    var vbad = parseInt(document.getElementById("good").innerHTML);
                    $("#good").html(vbad + 1);
                }
            });
        });

        //踩文章
        $("#dbad").click(function () {
            $.post("/post/dig?mod=bad&id=@Model.PostID", function (data) {
                alert(data);
                if (data == "操作成功") {
                    var vbad = parseInt(document.getElementById("bad").innerHTML);
                    $("#bad").html(vbad + 1);
                }
            });
        });

        function checomment() {
            if ($("#nickname").val() == "") {
                alert("请填写昵称");
                return false;
            }
            if ($("#comment").val() == "") {
                alert("请填写评论内容");
                return false;
            }
            return true;
        }
        getcomment();
        function getcomment() {
            $.post("/comment/getcomment/@Model.PostID", function (data) {
                $("#showcomment").html(data);
            });
        }
    });
</script>
<fieldset>
    <div id="nav">
        <a href="/">首页</a> >><a href="/post/bytype/@Model.PostTypeID">@Model.GetPostType().TypeName</a>
        >> @Model.Title</div>
    <legend></legend>
    <br />
    <div style="text-align: center; font-size: large; font-weight: bold;">
        <span>@Model.Title</span></div>
    <div id="postbody" style="width: auto; text-align: justify;">
        <div class="display-label" style="text-align: center;">
            <label>
                分类:@Model.GetPostType().TypeName
            </label>
            <label>
                作者:@Model.GetUser().UserName
            </label>
            <label>
                时间:@Html.DisplayFor(model => model.PubTime)</label>
            <label>
                点击:@Html.DisplayFor(model => model.Click)</label>
        </div>
        <br />
        <div class="display-label">
            @Html.Raw(Model.Content)
        </div>
        <div style="text-align: center;">
            <ul>
                <li id="dgood" style="cursor: pointer;">顶一下 <span id="good">@Model.DigGood</span>
                </li>
                <li id="dbad" style="cursor: pointer;">踩一下 <span id="bad">@Model.DigBad</span></li>
            </ul>
        </div>
    </div>
    <div class="display-field">
        <form id="form1">
        <fieldset>
            <legend>评论</legend>
            <br />
            <div>
                昵称:<input type="text" id="nickname" />
            </div>
            <div>
                邮箱:<input type="text" id="email" /></div>
            <div>
                主页:<input type="text" id="siteurl" /></div>
            <div>
                内容:</div>
            <div>
                <textarea name="comment" id="comment" style="width: 400px; height: 120px;"></textarea>
            </div>
            <input id="btncomment" type="button" value="评论" />
            <br />
            <hr />
            <div id="showcomment">
            </div>
        </fieldset>
        </form>
</fieldset>
